
import request from '@/utils/request'

// 获取某个角色已分配的权限
export function getRolePermissions(roleId) {
    return request.get(`/admin/role-permissions/${roleId}`)
}

// 分配权限给角色
export function assignPermissions({ roleId, permissionIds }) {
    return request.post(`/admin/role-permissions`, {
        roleId,
        permissionIds
    })
}

export const pagePermissions = (params) =>
    request.get('/admin/permissions', { params });

// 获取所有可用权限列表
export function listAllPermissions() {
    return request.get('/admin/permissions', { params: { pageNum: 1, pageSize: 100 } })
}


// 创建
export const createPermission = (data) =>
    request.post('/admin/permissions', data);

// 更新
export const updatePermission = (data) =>
    request.put('/admin/permissions', data);

// 删除（批量）
export const deletePermissions = (ids) =>
    // 后端接收 ?ids=1,2,3
    request.delete('/admin/permissions', { params: { ids } });
